﻿@model GenDbTableDto
@{
    var className = Model.EntityName;
    var classNameRemark = Model.DisplayName;
}
<pre>
namespace @(Model.Namespace).Api.Admin.Controllers.Apps;

/// <summary>
/// @(classNameRemark) 控制器
/// </summary>
[ControllerDescriptor(MenuId = "请设置菜单Id 系统菜单表中查找,如果不设置不受权限保护!", DisplayName = "@(classNameRemark)")]
public class @(className)Controller : AdminControllerBase<@($"{className}Service")>
{
    public @(className)Controller(@(className)Service defaultService) 
        : base(defaultService)
    {

    }
        
    /// <summary>
    /// 获取列表
    /// </summary>
    /// <param name="pagingSearchInput"></param>
    /// <returns></returns>
    [ActionDescriptor(PermissionFunctionConsts.Function_Display, DisplayName = "查看数据")]
    [HttpPost]
    public Task<@("PagingView")> FindListAsync([FromBody] PagingSearchInput<@(className)> pagingSearchInput)
    {
        return this._defaultService.FindListAsync(pagingSearchInput);
    }

    /// <summary>
    /// 根据id数组删除
    /// </summary>
    /// <param name="ids">ids</param>
    /// <returns></returns>
    [ActionDescriptor(PermissionFunctionConsts.Function_Delete, DisplayName = "删除数据")]
    [HttpPost]
    public async Task<@("bool")> DeleteListAsync([FromBody] List<@("Guid")> ids)
    {
        await this._defaultService.DeleteListAsync(ids);
        return true;
    }

    /// <summary>
    /// 查询表单数据
    /// </summary>
    /// <param name="id">id</param>
    /// <returns></returns>
    [ActionDescriptor(DisplayName = "查看表单")]
    [HttpGet("{id?}")]
    public Task<@Html.Raw("Dictionary<string, object>")> FindFormAsync([FromRoute] Guid id)
    {
        return this._defaultService.FindFormAsync(id);
    }

    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="form"></param>
    /// <returns></returns>
    [RequestLimitFilter(Duration = 1, LimitCount = 1)]
    [ActionDescriptor(PermissionFunctionConsts.Function_Insert, DisplayName = "创建表单")]
    [HttpPost]
    [ApiCheckModel]
    public Task CreateAsync([FromBody] @(className) form)
    {
        return this._defaultService.SaveFormAsync(form);
    }

    /// <summary>
    /// 编辑
    /// </summary>
    /// <param name="form"></param>
    /// <returns></returns>
    [RequestLimitFilter(Duration = 1, LimitCount = 1)]
    [ActionDescriptor(PermissionFunctionConsts.Function_Update, DisplayName = "编辑表单")]
    [HttpPost]
    [ApiCheckModel]
    public Task UpdateAsync([FromBody] @(className) form)
    {
        return this._defaultService.SaveFormAsync(form);
    }

    /// <summary>
    /// 导出Excel
    /// </summary>
    /// <param name="pagingSearchInput"></param>
    /// <returns></returns>
    [ActionDescriptor(PermissionFunctionConsts.Function_Export, DisplayName = "导出数据")]
    [ApiResourceCacheFilter(10)]
    [HttpPost]
    public async Task ExportExcelAsync([FromBody] PagingSearchInput<@(className)> pagingSearchInput)
    {
        var data = await this._defaultService.ExportExcelAsync(pagingSearchInput);
        var name = $"{PermissionUtil.GetControllerDisplayName(this.GetType())}列表数据 {DateTime.Now.ToString("yyyy-MM-dd")}.xls";
        base.HttpContext.DownLoadFile(data, Tools.GetFileContentType[".xls"].ToStr(), name);
    }




}

</pre>